package com.fafi.spring.test.beanprocessor;

import com.fafi.spring.test.TestBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class SelfBeanProcessor implements BeanPostProcessor {
	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessBeforeInitialization:"+beanName);
		Object reto = null;
		if("testBean".equals(beanName)) {
			TestBean o = new TestBean();
			TestBean testBean = (TestBean)bean;
			o.setName("--"+testBean.getName()+"--postProcessBeforeInitialization");
			reto = o;
		}
		return reto;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessAfterInitialization:bean:"+bean+"---"+beanName);
		return null;
	}
}
